<?php
   $csv_output = "name,address,city,state,zip,country"; 
   $csv_output .= "\n"; 
//outputs everything separated by commas
   foreach($confregs as $reg) { 
		$person = $reg->getRegistrantId();
        $person2 = RegistrantPeer::retrieveByPK($person);
		$n = $person2->getName();
		$a = $person2->getAddress();
		$c = $person2->getCity();
		$s = $person2->getState();
		$z = $person2->getZipCode();
		$co = $person2->getCountry();
       $csv_output .= "$n,$a,$c,$s,$z,$co\n";
       } 
//this is where you set file specific settings
   header("Content-type: application/vnd.ms-excel");
   header("Content-disposition:  attachment; filename=confmailings_".date("Y-m-d").".csv");
   print $csv_output;
   exit;  
?>